{extend name="base"/}
{block name="title"}
   {:lang('确认订单')}
{/block}
{block name="css"}
<link rel="stylesheet" href="__MOBILE__/css/wy.css">
<style>
    body{background: #f5f5f5;}
    .bu_messages{margin-top: 1.08rem; background:url("__SHOP__/images/store/bottom.png") no-repeat 50% 100%;background-color: #fff;}
    .goods{background: #fff;margin-bottom: 0.2rem;}
    .invo .money {
        width: 2.6rem; 
    }
    .invo .a_of {
        margin-left: 0rem; 
    }
    .subto .subto_left {
    float: right;
    height: 0.8rem;
    margin-right: 2%;
}
.subtop{line-height:.8rem;height:.8rem;margin-left:.3rem;font-size: .32rem;}
.dist_num{text-align:right;margin-top: -.8rem;}
.header_mess{float: right;width: 20%;height: 1rem;text-align:center;margin-top:.3rem;}
.addbg{background:#fff;display:block;padding-bottom:.5rem;}
.list_t {border-bottom: 0.02rem solid #eee;}
.desc{margin-top:.3rem;overflow: hidden; text-overflow:ellipsis; white-space: nowrap; }
</style>
{/block}
{block name="content"}
<!-- 头部 -->
<div class="head">
        <div class="head_left">
            <a href="javascript:history.go(-1)"><img src="__MOBILE__/images/true.png" alt=""></a>
        </div>
        <div class="head_con">{:lang('确认订单')}</div>
    </div>
   {if $address}
    <div class="bu_messages">
        <a href="/langjinmobile/merchandise/addmar" class="addbg">
            <span class="ownmess">{:lang('收货人')}:{$address.username}</span>
            <span class="bu_tel">{$address.mobile}</span>
            <div class="clr"></div>
                <div class="bu_ordericon">
                    <img src="__MOBILE__/images/daohengicon.png" alt="">
                </div>
                <input type="hidden" name="address" value="{$address.id}">
                <div class="bu_orderaddress">
                    
                        {$address['province'].$address['city'].$address['area'].$address['street'].$address['address']}                     
                </div>
                <div class="clr"></div>
            <!-- <span class="agasintime">订单创建时间</span>
            <span class="bu_time">2019-01-24 16:54</span> -->
        </a>
    </div>
    <!-- 没有选择地址 -->
    {else /}
    <div class="bu_addressblock">
            <a href="/langjinmobile/merchandise/addmar">
                <img src="__MOBILE__/images/addplus.png" alt="" class="addplus">
             </a>
                 <div class="addnewaddress">添加新的地址</div>
        </div>
    {/if}
    
   
   {if count($res)>0}
    <div class="goods">
            {volist name="res" id="vo"}
            {volist name="vo.goods" id="vos"}
            <ul class="detail">
                <li>
                    <div class="list_t">
                        <a href="/shop/store/mallxq.html">
                            <img src="{$vos.img1}" alt="">
                            <h4>{:lang('店铺')}{$vo.business.name}</h4>
                            <!-- <div class="con_right">
                                <p class="model">颜色：黑色</p>
                                <p class="model" style="margin-top:0;">尺码：M号</p>
                            </div> -->
                            
                            <p class="desc">{$vos.good_name}</p>
                            <div class="con_right">
                                <p class="mon">￥
                                    <span class="yue">{$vos.wallet_num}</span>+
                                    <span class="jfen">{$vos.integral_num}</span>GMOD
                                </p>
                                <p class="onum">x<span class="jian">{$vos.num}</span></p>
                            </div>
                            
                        </a>
                    </div>
                </li>
            </ul>
            {/volist}
             {/volist} 
            <div class="subto">
                <div class="subto_left">
                   合计：<span class="shop_jin">200+200GMOD</span>
                </div>
            </div>
        </div>
     {else /}
    <div class="goods">数据为空！</div>
    {/if}


    <div class="way">
            <div class="dist">创建时间       
                <p class="dist_num">{:date("Y-m-d H:i",time())}</p>
            </div>
            <!-- <div class="dist">快递单号        
                <p class="dist_num">1111111111111111111</p>
            </div> -->
            <div class="dist">配送方式        
                <p class="dist_ch">普通快递</p>
            </div>
            <div class="leave">
                买家留言: <input type="text" name="note" placeholder="填写内容和卖家协商确认（选填）">
            </div>
        </div>

       
  
        <div class="invo">
                <div class="a_of">共: <span class="two">{$tnum}</span> 件</div>
                <div class="money"><span>￥</span><span class="number">200+200GMOD</span></div>
                <div class="sub_mit" id="but_tijiao"><a href="javascript:vod(0);">提交订单</a></div>
            </div>

{/block}
{block name="js"}

<script>
	var att = 0;
	var jifen = 0;
    all_tol();
    function all_tol(){
            var $elements = $('.detail');
            var len = $elements.length;
			att = 0;
			jifen = 0;
			for(var i = 0; i < len; i++){
                att = att + parseInt(parseInt($(".detail").children("li").children(".list_t").children("a").children(".con_right").children(".mon").find(".yue").eq(i).html())
                            *parseInt($(".detail").children("li").children(".list_t").children("a").children(".con_right").children(".onum").find(".jian").eq(i).html()));
				jifen = jifen + parseInt(parseInt($(".detail").children("li").children(".list_t").children("a").children(".con_right").children(".mon").find(".jfen").eq(i).html())
                *parseInt($(".detail").children("li").children(".list_t").children("a").children(".con_right").children(".onum").find(".jian").eq(i).html()));
                console.log(jifen)
			}
			$(".subto_left .shop_jin").html(att +' + '+ jifen+"GMOD");
            $(".number").html(att +' + '+ jifen+"GMOD");
            var jian =$('.jian').text();
		};

    
    $(".dist_ch").eq(0).click(function(){
        $(".pop_con_tit").html("{:lang('普通快递')}");
        $(".pop_con_con p").html("{:lang('详情请咨询具体商家')}");
        $(".popup").show();
    });
    $(".dist_ch").eq(1).click(function(){
        $(".pop_con_tit").html("{:lang('运费')}");
        $(".pop_con_con p").html("{:lang('详情请咨询具体商家')}");
        $(".popup").show();
    });

    $(".pop_last").click(function(){
        $(".popup").hide();
    });
    
    $('#but_tijiao').click(function(){
        
        var addressid=$('input[name="address"]').val();
        var note=$('input[name="note"]').val();
        if(addressid){
            $.post('/langjinmobile/Card/saveaddress',{addressid:addressid,note:note},function(data){

                if(data.status==1){
                    window.location.href = "/langjinmobile/Card/zhiok/";
                }else{
                    msg_alert('收货地址错误！');
                }
            })
        }else{
            msg_alert('收货地址错误！');
        }
    })
</script>

{/block}
